package com.jinmdz.fmis.api.api.controller;

import com.jinmdz.fmis.api.api.model.common.IdVersionData;
import com.jinmdz.fmis.api.api.model.funeral.FuneralSuppliesData;
import com.jinmdz.fmis.api.api.service.FuneralSuppliesService;
import com.jinmdz.fmis.api.base.BaseController;
import com.jinmdz.fmis.core.base.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 丧葬用品任务信息相关接口
 *
 * @author LiCongLu
 * @date 2020-01-20 11:23
 */
@Api(description = "丧葬用品任务信息相关接口")
@RestController()
@RequestMapping("/api/funeral-supplies")
public class FuneralSuppliesController extends BaseController {

    @Resource
    private FuneralSuppliesService funeralSuppliesService;

    /**
     * 保存丧葬用品洽谈信息到费用表中
     *
     * @param data 丧葬用品
     * @return
     * @author LiCongLu
     * @date 2020-02-15 22:53
     */
    @ApiOperation(value = "保存丧葬用品洽谈信息到费用表中", notes = "保存丧葬用品任务信息到费用表中")
    @PostMapping("/save-funeral-supplies")
    public BaseResult<FuneralSuppliesData> saveFuneralSupplies(@RequestBody FuneralSuppliesData data) {
        return resultHandler(data, userItem -> funeralSuppliesService.saveFuneralSupplies(userItem, data));
    }

    /**
     * 从费用表中删除指定id的丧葬用品任务信息记录
     *
     * @param data 主键和版本号
     * @return
     * @author LiCongLu
     * @date 2020-02-15 22:50
     */
    @ApiOperation(value = "从费用表中删除指定id的丧葬用品任务信息记录", notes = "从费用表中删除指定id的丧葬用品任务信息")
    @PostMapping("/delete-funeral-supplies-with-id")
    public BaseResult deleteFuneralSuppliesWithId(@RequestBody IdVersionData data) {
        return resultHandler(data, userItem -> funeralSuppliesService.deleteFuneralSuppliesWithId(userItem, data));
    }
}
